package com.example.coursehub.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Getter
@Setter
@Entity
@Table(name = "wrong_question_bank_question", schema = "courseHub")
public class WrongQuestionBankQuestion {
    @EmbeddedId
    private WrongQuestionBankQuestionId id;

    @MapsId("wrongQuestionBankId")
    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JoinColumn(name = "wrong_question_bank_id", nullable = false)
    private WrongQuestionBank wrongQuestionBank;

    @MapsId("questionId")
    @ManyToOne(fetch = FetchType.EAGER, optional = false)
    @OnDelete(action = OnDeleteAction.CASCADE)
    @JoinColumn(name = "question_id", nullable = false)
    private Question question;
        public String getQuestionId() {
        return this.id != null ? this.id.getQuestionId() : null;
    }
}